// +build darwin linux

package finder

import "syscall"

func (c *Catalog) Close() (err error) {
	if c.isMmap {
		err = syscall.Munmap(c.Data)
	} else {
		c.Data = nil
	}
	return
}

func (c *Catalog) MemoryMap(fd int, offset int64, size int) (err error) {
	c.Data, err = syscall.Mmap(fd, offset, size, syscall.PROT_READ, syscall.MAP_SHARED)
	c.isMmap = (err == nil)
	return
}
